<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>reply_to_conversation (Sergi::Acts::Messageable::InstanceMethods)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File lib/acts_as_messageable.rb, line 163</span>
        <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reply_to_conversation</span>(<span class="ruby-identifier">conversation</span>, <span class="ruby-identifier">reply_body</span>, <span class="ruby-identifier">subject</span> = <span class="ruby-keyword kw">nil</span>)
          <span class="ruby-comment cmt">#move conversation to inbox if it is currently in the trash - doesnt make much sense replying to a trashed convo.</span>
          <span class="ruby-keyword kw">if</span>((<span class="ruby-identifier">mailbox</span>[<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">mailbox_types</span>[<span class="ruby-identifier">:deleted</span>]].<span class="ruby-identifier">has_conversation?</span>(<span class="ruby-identifier">conversation</span>)))
            <span class="ruby-identifier">mailbox</span>.<span class="ruby-identifier">move_to</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">mailbox_types</span>[<span class="ruby-identifier">:received</span>], <span class="ruby-identifier">:conversation</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">conversation</span>)
          <span class="ruby-keyword kw">end</span>
          <span class="ruby-comment cmt">#remove self from recipients unless you are the originator of the convo</span>
          <span class="ruby-identifier">recipients</span> = <span class="ruby-identifier">conversation</span>.<span class="ruby-identifier">original_message</span>.<span class="ruby-identifier">recipients</span>.<span class="ruby-identifier">clone</span>()
          <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">conversation</span>.<span class="ruby-identifier">originator</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">self</span>)
            <span class="ruby-identifier">recipients</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-keyword kw">self</span>)
            <span class="ruby-keyword kw">if</span>(<span class="ruby-operator">!</span><span class="ruby-identifier">recipients</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">conversation</span>.<span class="ruby-identifier">originator</span>))
              <span class="ruby-identifier">recipients</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">conversation</span>.<span class="ruby-identifier">originator</span>
            <span class="ruby-keyword kw">end</span>
          <span class="ruby-keyword kw">end</span>
          <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">reply</span>(<span class="ruby-identifier">conversation</span>,<span class="ruby-identifier">recipients</span>, <span class="ruby-identifier">reply_body</span>, <span class="ruby-identifier">subject</span>)
        <span class="ruby-keyword kw">end</span></pre>
</body>
</html>